﻿package  
{
	
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.events.Event;
	
	
	public class BattleGirdMC extends MovieClip 
	{
		public var type:int = 0;
		public var index:int = 0;
		
		private var timer:Timer = new Timer( 10 );
		
		public function BattleGirdMC()
		{
			// constructor code
			
			hit.visible = false;
			hpText.visible = false;
			
			this.mouseEnabled = false;
			hit.mouseEnabled = false;
			fall.visible = false;
			
			timer.addEventListener( TimerEvent.TIMER , onTimer );
		}
		
		public function clear():void
		{
			hit.visible = false;
			hpText.visible = false;
			
			fall.Fall( false );
		}
		
		private function onTimer( e:TimerEvent ):void
		{
			hpText.y -= 1.2;
			hpText.alpha -= 0.007;
			
			if ( hpText.alpha <= 0.5 )
			{
				timer.stop();
				hpText.alpha = 1.0;
				hpText.visible = false;
			}
		}
		
		public function Hit( x1:int = 0 , y1:int = 0 ):void
		{
			hit.x = x1;
			hit.y = y1;
			
			hit.visible = true;
			hit.gotoAndPlay( 0 );
		}
		
		public function Jump( hp:int ):void
		{
			hpText.visible = true;
			hpText.y = -32.2;
			hpText.alpha = 1.0;
			hpText.text = hp.toString();
			
			timer.start();
		}
		
		public function Fall( b:Boolean , x1:int = 0 , y1:int = 0 ):void
		{
			fall.x = x1;
			fall.y = y1;
			
			fall.Fall( b );
		}
		
	}
	
}
